package zyy.util;

import java.sql.Connection;
import java.sql.SQLException;

// public class DBUtil {
public class DBUtil {
  private static final String jdbcUrl = "jdbc:mysql://localhost:3306/TakeawayGo?useUnicode=true&characterEncoding=utf8&useSSL=false";
  // private static final String jdbcUrl =
  // "jdbc:mysql://localhost:3306/booklib?useUnicode=true&characterEncoding=utf8";
  private static final String dbUser = "root";
  private static final String dbPwd = "1";
  static {
    try {
      Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
  }

  public static Connection getConnection() throws java.sql.SQLException {
    return java.sql.DriverManager.getConnection(jdbcUrl, dbUser, dbPwd);
  }

  public static void main(String[] args) throws SQLException {
    Connection conn = DBUtil.getConnection();
    System.out.println(conn);
  }
}
